/*
 * Improbability Drive
 * Phillip Cardon, Thach Nguyen, Cristopher Claeys
 * 4/26/2011
 */

package testers;

import java.net.MalformedURLException;
import java.net.URL;

import org.jsoup.nodes.Document;

import structures.Reporter;
import structures.Tuple;

import background.DataGatherer;
import background.PageParser;
import background.PageRetriever;
import buffers.SynchronizedBuffer;
import buffers.URLsRetrieved;

public class RetrivePage {
	public static void main (String args[]) {
		SynchronizedBuffer<URL> toRetrieve = new SynchronizedBuffer<URL>();
		URLsRetrieved got = new URLsRetrieved();
		SynchronizedBuffer<Tuple<Document, URL>> downloaded = new SynchronizedBuffer<Tuple<Document,URL>>();
		PageRetriever pr = new PageRetriever(toRetrieve, downloaded, got, 15);
		String[] keys = {"mobus", "research"};
		Reporter rp = new Reporter(keys, 10);
		DataGatherer dg = new DataGatherer(keys, rp);
		PageParser pp = new PageParser(toRetrieve, downloaded, dg);
		URL seed = null; //zomg code smell
		try {
			seed = new URL("http://faculty.washington.edu/gmobus/");
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			System.out.println("SEED IS INVALID");
		}
		toRetrieve.enqueue(seed);
		pr.run();
		pp.run();
		dg.run();
		System.out.println(toRetrieve.size());
	}
}
